local longdan = fk.CreateSkill{
  name = "iberia__longdan",
}

Fk:loadTranslationTable{
  [longdan.name] = "龙胆",
  [":"..longdan.name] = "你可以将【杀】当【闪】／将【闪】当【杀】使用／打出，然后可以令一名非当前回合角色摸一张牌。",
  [longdan.name.."-draw1"] = "龙胆：可以令一名非当前回合角色摸一张牌",
}

local ldata = {"slash", "jink"}

local canuse = function (player, to_select)
  local card = Fk:getCardById(to_select)
  if table.contains(ldata, card.trueName) then
    local name = ldata[3-table.indexOf(ldata, card.trueName)]
    local _card = Fk:cloneCard(name)
    if Fk.currentResponsePattern then
      return Exppattern:Parse(Fk.currentResponsePattern):match(_card)
    else
      return player:canUse(_card)
    end
  end
end

longdan:addEffect("viewas", {
  anim_type = "special",
  pattern = "slash,jink",
  card_filter = function (self, player, to_select, selected)
    if #selected > 0 then return end
    return canuse(player, to_select)
  end,
  view_as = function (self, player, cards)
    if #cards ~= 1 then return end
    local card = Fk:getCardById(cards[1])
    local _card = Fk:cloneCard(ldata[3-table.indexOf(ldata, card.trueName)])
    _card.skillName = longdan.name
    _card:addSubcards(cards)
    return _card
  end
})

local tri = {
  anim_type = "drawcard",
  can_trigger = function (self, event, target, player, data)
    return player == target and table.contains(data.card.skillNames, longdan.name)
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      targets = table.filter(room.alive_players, function(p) return p ~= room.current end ), min_num = 1, max_num = 1,
      prompt = longdan.name.."-draw1", skill_name = longdan.name, cancelable = true
    })
    if #to == 0 then return end
    event:setCostData(self, to[1])
    return true
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:drawCards(event:getCostData(self), 1, longdan.name)
  end,
}

longdan:addEffect(fk.CardUseFinished, tri)
longdan:addEffect(fk.CardRespondFinished, tri)

return longdan